<template>
  <div v-if="visible" class="bottom-bar" :class="sidebarClass">
    <div class="bottom-bar-content">
      <div class="bottom-bar-left">
        <slot name="left"></slot>
      </div>
      <div class="bottom-bar-right">
        <slot name="right"></slot>
      </div>
    </div>
  </div>
</template>

<script>
import useAppStore from '@/store/modules/app'

export default {
  name: 'BottomBar',
  props: {
    visible: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    appStore() {
      return useAppStore()
    },
    sidebarClass() {
      return {
        'hide-sidebar': !this.appStore.sidebar.opened
      }
    }
  }
}
</script>

<style scoped>
/* 底部固定操作栏 */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 200px; /* 默认展开状态宽度 */
  right: 0;
  height: 60px;
  background: #ffffff;
  box-shadow: 0 -2px 12px 0 rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  transition: left 0.28s; /* 添加过渡动画 */
}

/* 菜单收缩时的样式 */
.bottom-bar.hide-sidebar {
  left: 44px; /* 收缩状态宽度 */
}

.bottom-bar-content {
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bottom-bar-left {
  flex: 1;
}

.bottom-bar-right {
  display: flex;
  gap: 12px;
}
</style>